/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
package rg1collectiondemo;

import java.util.ArrayList;
import java.util.Collection;
import java.util.Iterator;
import java.util.List;
import java.util.Map;

/**
 *
 * @author apple
 */
public class CollectionForEach {
    public static void show(Collection collection)
    {
        Iterator it=collection.iterator();
        while(it.hasNext())
        {
            System.out.print(it.next()+" ,");
        }
        System.out.println("");
    }
    
    public static void show(Map map)
    {
        Iterator it=map.entrySet().iterator();
        while(it.hasNext())
        {
            Map.Entry<Integer,String> entry=(Map.Entry<Integer, String>)it.next();
            System.out.println("Key="+entry.getKey()+";Value="+entry.getValue());
        }
    }
}
